<?php	
	function strDecode($str){
		$a = '‘’àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ';
		$b = '\'\'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY';
		return strtr(utf8_decode($str), utf8_decode($a), utf8_decode($b));
	}

	function printFormattedText($pdf, $text, $fontSize){
		$pdf->setFontSize($fontSize);
		$i = 0;
		while($i < strlen($text)){
			$j = 0;		
			while($pdf->GetStringWidth(substr($text, $i, $j)) < 180 && $i + $j < strlen($text)){
				$m = 1;
				while($i + $j + $m < strlen($text) && $text[$j + $i + $m] != ' ' && $text[$j + $i + $m] != '.'){
					$m++;
				}
				//On teste si le prochain mot peut etre affiché sur la ligne
				if($pdf->GetStringWidth(substr($text, $i, $j + $m)) < 180){
					$j = $j + $m;
				}
				else{
					$j++;
					break;
				}
			}
			
			$pdf->Cell(40,10,substr($text, $i, $j),0,0);
			$pdf->Ln($fontSize/2);
			$i = $j + $i;
		}
	}
?>
